class RestaurantModel {
  int? totalSize;
  String? limit;
  String? offset;
  List<Restaurant>? restaurants;

  RestaurantModel({this.totalSize, this.limit, this.offset, this.restaurants});

  RestaurantModel.fromJson(Map<String, dynamic> json) {
    totalSize = json['total_size'];
    limit = json['limit'].toString();
    offset = json['offset'].toString();
    if (json['restaurants'] != null) {
      restaurants = [];
      json['restaurants'].forEach((v) {
        restaurants?.add(new Restaurant.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['total_size'] = this.totalSize;
    data['limit'] = this.limit;
    data['offset'] = this.offset;
    if (this.restaurants != null) {
      data['restaurants'] = this.restaurants!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Restaurant {
  int? id;
  int? status;
  String? name;
  String? phone;
  String? email;
  String? logo;
  String? latitude;
  String? longitude;
  String? address;
  double? minimumOrder;
  String? currency;
  String? openingTime;
  String? closeingTime;
  bool? freeDelivery;
  String? coverPhoto;
  bool? delivery;
  bool? takeAway;
  bool? scheduleOrder;
  double? avgRating;
  double? tax;
  double? serviceCharge;
  int? ratingCount;
  String? offDay;
  int? selfDeliverySystem;
  bool? posSystem;
  double? deliveryCharge;
  int? open;
  bool? active;
  String? deliveryTime;
  List<int>? categoryIds;
  int? veg;
  int? nonVeg;
  Discount? discount;
  int? avgPrice;
  bool? too_far;
  String? distance;
  double? deliveryFee;
  bool? is_open;

  Restaurant(
      {this.id,
      this.status,
      this.name,
      this.phone,
      this.email,
      this.logo,
      this.latitude,
      this.longitude,
      this.address,
      this.minimumOrder,
      this.currency,
      this.openingTime,
      this.closeingTime,
      this.freeDelivery,
      this.coverPhoto,
      this.delivery,
      this.takeAway,
      this.scheduleOrder,
      this.avgRating,
      this.tax,
      this.serviceCharge,
      this.ratingCount,
      this.offDay,
      this.selfDeliverySystem,
      this.posSystem,
      this.deliveryCharge,
      this.open,
      this.active,
      this.deliveryTime,
      this.categoryIds,
      this.veg,
      this.nonVeg,
      this.discount,
      this.avgPrice,
      this.distance,
      this.too_far,
      this.deliveryFee,
      this.is_open});

  Restaurant.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    status = json['status'];
    name = json['name'];
    phone = json['phone'];
    email = json['email'];
    logo = json['logo'] != null ? json['logo'] : '';
    latitude = json['latitude'];
    longitude = json['longitude'];
    address = json['address'];
    minimumOrder = json['minimum_order'].toDouble();
    currency = json['currency'];
    openingTime = json['available_time_starts'];
    closeingTime = json['available_time_ends'];
    freeDelivery = json['free_delivery'];
    coverPhoto = json['cover_photo'] != null ? json['cover_photo'] : '';
    delivery = json['delivery'];
    takeAway = json['take_away'];
    scheduleOrder = json['schedule_order'];
    avgRating = json['avg_rating'].toDouble();
    tax = json['tax'] != null ? json['tax'].toDouble() : null;
    serviceCharge = json['service_charge'] != null
        ? json['service_charge'].toDouble()
        : null;
    ratingCount = json['rating_count '];
    offDay = json['off_day'];
    selfDeliverySystem = json['self_delivery_system'];
    posSystem = json['pos_system'];
    deliveryCharge = json['delivery_charge'].toDouble();
    open = json['open'];
    active = json['active'];
    deliveryTime = json['delivery_time'];
    veg = json['veg'];
    distance = json['distance'].toString();
    avgPrice = json['avgPrice'];
    nonVeg = json['non_veg'];
    categoryIds =
        json['category_ids'] != null ? json['category_ids'].cast<int>() : [];
    discount = json['discount'] != null
        ? new Discount.fromJson(json['discount'])
        : null;
    too_far = json['too_far'];
    deliveryFee = json['delivery_fee'] == null
        ? json['delivery_fee']
        : json['delivery_fee'].toDouble();
    is_open = json['is_open'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['status'] = this.status;
    data['name'] = this.name;
    data['phone'] = this.phone;
    data['email'] = this.email;
    data['logo'] = this.logo;
    data['latitude'] = this.latitude;
    data['longitude'] = this.longitude;
    data['address'] = this.address;
    data['minimum_order'] = this.minimumOrder;
    data['currency'] = this.currency;
    data['available_time_starts'] = this.openingTime;
    data['available_time_ends'] = this.closeingTime;
    data['free_delivery'] = this.freeDelivery;
    data['cover_photo'] = this.coverPhoto;
    data['delivery'] = this.delivery;
    data['take_away'] = this.takeAway;
    data['schedule_order'] = this.scheduleOrder;
    data['avg_rating'] = this.avgRating;
    data['tax'] = this.tax;
    data['service_charge'] = this.serviceCharge;
    data['rating_count '] = this.ratingCount;
    data['off_day'] = this.offDay;
    data['self_delivery_system'] = this.selfDeliverySystem;
    data['pos_system'] = this.posSystem;
    data['delivery_charge'] = this.deliveryCharge;
    data['open'] = this.open;
    data['active'] = this.active;
    data['veg'] = this.veg;
    data['non_veg'] = this.nonVeg;
    data['delivery_time'] = this.deliveryTime;
    data['category_ids'] = this.categoryIds;
    if (this.discount != null) {
      data['discount'] = this.discount!.toJson();
    }
    data['too_far'] = this.too_far;
    data['delivery_fee'] = this.deliveryFee;
    return data;
  }
}

class Discount {
  int? id;
  String? startDate;
  String? endDate;
  String? startTime;
  String? endTime;
  double? minPurchase;
  double? maxDiscount;
  double? discount;
  String? discountType;
  int? restaurantId;
  String? createdAt;
  String? updatedAt;
  bool? discountIsOpen;

  Discount(
      {this.id,
      this.startDate,
      this.endDate,
      this.startTime,
      this.endTime,
      this.minPurchase,
      this.maxDiscount,
      this.discount,
      this.discountType,
      this.restaurantId,
      this.createdAt,
      this.updatedAt,
      this.discountIsOpen});

  Discount.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    startDate = json['start_date'];
    endDate = json['end_date'];
    startTime =
        json['start_time'] != null ? json['start_time'].substring(0, 5) : null;
    endTime =
        json['end_time'] != null ? json['end_time'].substring(0, 5) : null;
    minPurchase = json['min_purchase'].toDouble();
    maxDiscount = json['max_discount'].toDouble();
    discount = json['discount'].toDouble();
    discountType = json['discount_type'];
    restaurantId = json['restaurant_id'];
    createdAt = json['created_at'];
    updatedAt = json['updated_at'];
    discountIsOpen = json['discount_is_open'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['start_date'] = this.startDate;
    data['end_date'] = this.endDate;
    data['start_time'] = this.startTime;
    data['end_time'] = this.endTime;
    data['min_purchase'] = this.minPurchase;
    data['max_discount'] = this.maxDiscount;
    data['discount'] = this.discount;
    data['discount_type'] = this.discountType;
    data['restaurant_id'] = this.restaurantId;
    data['created_at'] = this.createdAt;
    data['updated_at'] = this.updatedAt;
    data['discount_is_open'] = this.discountIsOpen;
    return data;
  }
}
